﻿using System;
using System.Windows.Forms;

namespace Homework1
{
    public partial class SettingsWindow : Form
    {
        public SettingsWindow()
        {
            InitializeComponent();
            
            DB.LoadSettings();

            AddressTextBox.Text = DB.Address;
            PortTextBox.Text = DB.Port.ToString();
            UsernameTextBox.Text = DB.Username;
            NameTextBox.Text = DB.DatabaseName;
        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            DB.Address = AddressTextBox.Text;
            DB.Port = Int32.Parse(PortTextBox.Text);
            DB.Username = UsernameTextBox.Text;
            DB.Password = PasswordTextBox.Text.ToSecureString();
            DB.DatabaseName = NameTextBox.Text;

            DB.SaveSettings();
        }
    }
}
